<template>
<uni-shadow-root class="partials-scanQrCode-scanQrCode"><view class="wrap" @click="scanQrCode">
<view class="scan">扫一扫</view>
<view class="scanImg">
  <image src="https://image1.sansancloud.com/xianhua/2019_12/17/14/51/53_424.jpg?x-oss-process=style/preview_120"></image>
</view>
</view></uni-shadow-root>
</template>

<script>

global['__wxRoute'] = 'partials/scanQrCode/scanQrCode'
const app = getApp();
Component({
  properties: {
    data: {
      type: JSON,
      value: 'default value',
    }
  },
  data: {
    someData: {}
  },
  methods: {
    tolinkUrl: function (event) {
      console.log(event.currentTarget.dataset.id)
      wx.navigateTo({
        url: '/pages/news_detail/index?id=' + event.currentTarget.dataset.id,
      })
    },
    scanQrCode:function(){
      wx.scanCode({
        onlyFromCamera: false,
        success: (res) => {
          console.log("========res=========",res)
          let json = "{" + res.result + "}";
          json = json.replace(/&/g, ',')
          json = json.replace(/=/g, ':')
          console.log(JSON.stringify(json))
          let json1 = res.result.replace(/=/g, ':')
          var surls = json1.split('&')
          console.log(surls[1])
          let aaa = surls[1].split(':')
          console.log(aaa);
            let ccc=JSON.stringify(aaa[0])
            let ddd =aaa[1]
          let bbb={
            ccc:ddd
          }
         console.log("=======bbb==========",bbb)
        }
      })
    }
  },
})
export default global['__wxComponents']['partials/scanQrCode/scanQrCode']
</script>
<style platform="mp-weixin">
.wrap{
   padding: 20rpx;
   display: flex;
   flex-direction: row;
}
.scan{
  width: 150rpx;
  height: 50rpx;
   font-size: 36rpx;
   line-height: 50rpx;
}
.scanImg{
  width: 50rpx;
  height: 50rpx;
}
.scanImg image{
  width: 50rpx;
  height: 50rpx;
}
</style>